Skip to content

Commit

Permalink
Improving NScurl integration
Browse files Browse the repository at this point in the history
  • Loading branch information
negrutiu committed Jun 3, 2024
1 parent 7603ab0 commit f556cea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 32 deletions.
36 changes: 15 additions & 21 deletions Contrib/NScurl/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from urllib import request

target = 'NScurl'

Import('BuildPlugin env')
Import('env')

scriptpath = Path((lambda x:x).__code__.co_filename)
scriptdir = scriptpath.parent
Expand All @@ -18,13 +18,12 @@ scriptdir = scriptpath.parent

unicode = 'UNICODE' in env['CPPDEFINES']
archdir = env['TARGET_ARCH'] + ('-unicode' if unicode else '-ansi') # x86-unicode|x86-amsi|amd64-unicode
root = scriptdir

# Download
pluginUrl = 'https://github.com/negrutiu/nsis-nscurl/releases/latest/download/NScurl.zip'
pluginZip = root.joinpath('Contrib', 'NScurl', 'latest', 'NScurl.zip')
pluginEtag = root.joinpath('Contrib', 'NScurl', 'latest', 'NScurl.etag')
pluginDir = root.joinpath('Contrib', 'NScurl', 'latest', 'package')
pluginZip = scriptdir.joinpath('github', 'NScurl.zip')
pluginEtag = scriptdir.joinpath('github', 'NScurl.etag')
pluginDir = scriptdir.joinpath('github', 'package')

print(f"Download {pluginUrl} to {pluginZip} ({archdir}) ...")
headers = {}
Expand Down Expand Up @@ -59,27 +58,22 @@ with ZipFile(pluginZip) as myzip:
shutil.rmtree(pluginDir, ignore_errors=True)
myzip.extractall(pluginDir)

# BuildPlugin
files = [
'main.c' # build a dummy NScurl.dll
]

libs = [
'kernel32'
]
# Distribute
Import('defenv')

examples = [
pluginDir.joinpath("Examples/NScurl/NScurl-Test.nsi"),
pluginDir.joinpath("Examples/NScurl/NScurl-Test-build.bat")
pluginDir.joinpath('Examples', 'NScurl', 'NScurl-Test.nsi'),
pluginDir.joinpath('Examples', 'NScurl', 'NScurl-Test-build.bat')
]

docs = [
pluginDir.joinpath("Docs/NScurl/NScurl.readme.md")
pluginDir.joinpath('Docs', 'NScurl', 'NScurl.readme.md')
]

BuildPlugin(target, files, libs, examples, docs)
plugins = [
pluginDir.joinpath('Plugins', archdir, 'NScurl.dll')
]

# Overwrite the dummy dll with the real one downloaded from GitHub
outdir = root.joinpath(env['BUILD_PREFIX'], 'NScurl', archdir) # <root>/nsis-mingw-negrutiu-x86/build/urelease/NScurl/x86-unicode, ('BUILD_PREFIX': 'build/urelease')
outdir.mkdir(parents=True, exist_ok=True)
shutil.copytree(pluginDir.joinpath('Plugins', archdir), outdir, dirs_exist_ok=True)
defenv.DistributeExamples(examples, path=target)
defenv.DistributeDocs(docs, path=target)
defenv.DistributePlugin(plugins, arcsubpath=archdir)
11 changes: 0 additions & 11 deletions Contrib/NScurl/main.c

This file was deleted.

0 comments on commit f556cea

Please sign in to comment.