Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,8 @@ def get_library(self, name, generated_libs, configure=['sh', './configure'], #
make = ['make']
if env_init is None:
env_init = {}
else:
env_init = env_init.copy()
if make_args is None:
make_args = ['-j', str(utils.get_num_cores())]

Expand Down Expand Up @@ -1234,8 +1236,9 @@ def get_library(self, name, generated_libs, configure=['sh', './configure'], #
configure += configure_args

cflags = ' '.join(cflags)
env_init.setdefault('CFLAGS', cflags)
env_init.setdefault('CXXFLAGS', cflags)
# Append library-specific cflags without overwriting caller-provided optimizations
env_init['CFLAGS'] = f"{env_init.get('CFLAGS', '')} {cflags}".strip()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about env_init.setdefault('CFLAGS', '') += cflags ?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't do += with a function call.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.extend() then?

env_init['CXXFLAGS'] = f"{env_init.get('CXXFLAGS', '')} {cflags}".strip()
return self.build_library(name, build_dir, generated_libs, configure,
make, make_args, cache_name, env_init=env_init, native=native)

Expand Down Expand Up @@ -1512,7 +1515,7 @@ def _build_and_run(self, filename, expected_output=None, args=None,
raise
return js_output

def get_freetype_library(self):
def get_freetype_library(self, env_init=None):
self.cflags += [
'-Wno-misleading-indentation',
'-Wno-unused-but-set-variable',
Expand All @@ -1524,10 +1527,11 @@ def get_freetype_library(self):
]
return self.get_library(os.path.join('third_party', 'freetype'),
os.path.join('objs', '.libs', 'libfreetype.a'),
env_init=env_init,
configure_args=['--disable-shared', '--without-zlib'])

def get_poppler_library(self, env_init=None):
freetype = self.get_freetype_library()
freetype = self.get_freetype_library(env_init=env_init)

self.cflags += [
'-I' + test_file('third_party/freetype/include'),
Expand Down
1 change: 1 addition & 0 deletions test/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def build(self, parent, filename, shared_args, emcc_args, native_args, native_ex
# systems (like zlib) if they see a CFLAGS it will override all their
# default flags, including optimizations.
env_init['CFLAGS'] = ' '.join(LLVM_FEATURE_FLAGS + [OPTIMIZATIONS] + self.cflags)
env_init['CXXFLAGS'] = env_init['CFLAGS']
# Avoid mutating incoming emcc_args
emcc_args = emcc_args.copy()
emcc_args += lib_builder('js_' + llvm_root, native=False, env_init=env_init)
Expand Down
Loading